package com.pwt.common;

import lombok.Data;

@Data
public class CustomException extends Exception {

    private static final long serialVersionUID = 1L;

    private String msg;
    private int code;
    private Object data;

    public CustomException() {
        this.code = 500;
    }

    public CustomException(String msg, Throwable cause) {
        super(msg,cause);
        this.msg = msg;
    }

    public CustomException(String msg, int code) {
        super(msg);
        this.code = code;
    }

    public CustomException(String msg, int code, Throwable cause) {
        super(msg,cause);
        this.msg = msg;
        this.code = code;
    }

    public CustomException(String msg) {
        super(msg);
        this.code = 500;
        this.msg = msg;
    }

    public CustomException(ResultCode resultCode) {
        super(resultCode.message());
        this.code = resultCode.code();
        this.msg = resultCode.message();
    }

    public CustomException(ResultCode resultCode, Object data) {
        super(resultCode.message());
        this.code = resultCode.code();
        this.msg = resultCode.message();
        this.data = data;
    }
}
